package org.jeecg.modules.qyxx.util;


import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ListUtil<T>{

    /**
     * @param dataList    目标list
     * @param pageSize    当前页大小
     * @param currentPage 当前页
     * @return 返回当前页的数据集
     * @deprecated 对list进行分页
     */
    public List<T> page(List<T> dataList, int pageSize, int currentPage) {
        List<T> currentPageList = new ArrayList<>();
        if (dataList != null && dataList.size() > 0) {
            int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
            for (int i = 0; i < pageSize && i < dataList.size() - currIdx; i++) {
                T data = dataList.get(currIdx + i);
                currentPageList.add(data);
            }
        }
        return currentPageList;
    }
}
